<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Insert title here</title>
		<link rel="stylesheet" href="../css/reg.css" type="text/css"></link> 
		<script type="text/javascript"
			src="../js/jquery-validation-1.10.0/lib/jquery-1.7.2.js"></script>
		<script type="text/javascript">  
		var id=2;  
		function ClickSubmit(){
			document.logForm.submit();
		}
		function addFile(){
			
			$("#addFile").append("<li id=fileLi"+id+"><input type='file' id='image_"+id+"' name='files' onChange='image_check("+id+")'/><a href='javascript:' onClick=removeFile("+id+++")>删除</a></li>")
			
		}
		function removeFile(id){
			$("#fileLi"+id).remove();
		}
		function changeCategory(){
			$("#category2").empty();
			$.ajax({
  			type: "POST",
   			url: "user!getCategory2.action",
   			data: "id="+$("#category1").val(),
   			success:function(txt){
   				for(var i=0;i<txt.length;i++){
   				$("#category2").append("<option value="+$.parseJSON(txt)[i].id+">"+$.parseJSON(txt)[i].name+"</option>");
   				}
   			}
			});
		}
		function image_check(id){
			
			var strSrc = $("#image_"+id).val();
			alert(strSrc);
			var pos = strSrc.lastIndexOf(".");
	       	var lastname = strSrc.substring(pos, strSrc.length);
	            if (lastname.toLowerCase() != ".jpg"&&lastname.toLowerCase() != ".png"&&lastname.toLowerCase() != ".gif"&&lastname.toLowerCase() != ".bmp") {
	               alert("您上传的文件类型为" + lastname + "，图片必须为 JPG、png、bmp、gif 类型","info");
	                return false;
	            }
	         
		}
		
		function deleteImg(id,name){
			$.ajax({
  			type: "POST",
   			url: "<%=path %>/changeGoods/changeGoods!deletePic.action",
   			data: "id="+id+"&name="+name,
   			success:function(){
   				$("#img_"+id).remove();
   				$("#imgbtn_"+id).remove();
   			}
			});
		}
	
		</script>
		<link rel="stylesheet" href="../css/Style.css" type="text/css"></link>
	</head>
	<body>
		<table width="980px" border="0" cellspacing="0" cellpadding="0"
			align="center">
			<tr>
				<td width="50%" height=80 rowspan=2>
					<div class=Mleft>

						<img src="../imgs/logo.gif" border=0>
					</div>
				</td>
				<td width="50%">
					<span id=AjaxShow></span>
					<br>
				</td>
			</tr>
			<tr>
				<td valign=bottom align=right>
					欢迎您：
					<strong><font color=red>沉黙de泠栤</font> </strong>
					<a href=/login.asp?Action=Logout target=_parent>退出</a>
				</td>
			</tr>
		</table>
		<table id=div border="0" cellspacing="0" cellpadding="0" align=center>
			<tr>
				<td>
					<img src=../imgs/center_top.gif>
				</td>
			</tr>
			<tr>
				<td
					style='padding: 5px; border-left: 1px #CCCCCC solid; border-right: 1px #CCCCCC solid'>
					<table border="0" cellspacing="0" cellpadding="0" align=center>
						<tr>
							<td width="155" valign=top>
								<jsp:include page="../frame/left.jsp" />

							</td>
							<td width="810" valign=top>
								<!-- right -->

								<div class=UserPath>
									您的位置：
									<a href=Index.asp>会员中心</a> >
									<a href=User_ClassAD.asp?ChannelID=2>分类信息管理</a>
								</div>

								<form action="<%=path%>/changeGoods/changeGoods!updateGoodsInfo.action"
									enctype="multipart/form-data" method="post">
									<table width='100%' cellpadding=0 cellspacing=1 class=td1>


										<tr>
											<td colspan=2 Class=td4>
												发布分类信息
												<font color='#000000'>(打红色*号的为必填项，如果发布不成功请联系客服协助解决QQ：378056439)</font>
											</td>
										</tr>
										<tr>
											<td width='50%' valign='top'>
												<table width='100%' cellpadding='0' cellspacing='0'>
													<tr>

														<td width='50%' valign='top'>
															<table width='100%' cellpadding='0' cellspacing='0'>
															
															</table>
														</td>

													</tr>

												</table>
											</td>
										</tr>
										<table width='100%' border='0' cellpadding='0' cellspacing='0'>
											<tr Class=td2>
												<td Class=ssdq>
													<strong>所属分类 <font color='#FF0000'>*</font> </strong>
												</td>
												<td Class=td6>
													

														<c:forEach items="${good.categorys}" var="cate">
					
															${cate.name }
														</c:forEach>

													
													<span id=ClassID1></span>
												</td>
											</tr>
											
											<tr Class=td2>
												<td width='20%'>
													<strong>信息标题 <font color='#FF0000'>*</font> </strong>
												</td>
												<td width='80%'>
													<input type="hidden" name="goods.id" value="${good.id }"/>
													<input type=text maxlength=100 name="goods.name" size=40
														onKeyUp="javascript:replaceInput(this,event)" value="${good.name }"/>
												</td>
											</tr>

											<tr Class=td2>
												<td valign=top>
													<strong>内容介绍 <font color='#FF0000'>*</font> </strong>
													<br/>

												</td>
												<td>
													<textarea id='Content' name='goods.content' cols="80"
														rows="20" style="resize: none">${good.content }</textarea>

												</td>
											</tr>
											<tr Class=td2>
												<td valign=top>
													<strong>图片 </strong>
													<br/>

												</td>
												<td id="picTd">
													<c:forEach items="${good.pic}" var="pic">
														<img id="img_${pic.id }" style="CURSOR: hand" onclick="window.open(this.src)"
															src="<%=path%>/user_images_${good.seller.id }/${pic.picUrl}"
															width="500" height="373"/>
															<input id="imgbtn_${pic.id }" type="button" onClick="deleteImg(${pic.id },'${pic.picUrl}')" value="删除"/>
													</c:forEach>

												</td>
											</tr>
										
											<tr Class=td2>
												<td valign=top>
													<strong>上传图片</strong>
													<br/>
													最大允许上传1M,支持批量上传
												</td>
												<td>
													<div style="width: 100px; float: left; display: block;">
														<ul id="addFile" style="width: 300px;">
															<li>
																<input type="file" id="image_1" name="files"
																	onChange="image_check(1)" />
																<a href="javascript:" onClick=addFile()>继续添加</a>
															</li>
														</ul>
													</div>
												</td>
											</tr>
											<tr Class=td2>
												<td>
													<strong>新旧程度</strong>
												</td>
												<td>
													<select name="goods.quality">
														<option value=10>
															10
														</option>
														<option value=9>
															9
														</option>
														<option value=8>
															8
														</option>
														<option value=7>
															7
														</option>
														<option value=6>
															6
														</option>
														<option value=5>
															5
														</option>
														<option value=4>
															4
														</option>
														<option value=3>
															3
														</option>
														<option value=2>
															2
														</option>
														<option value=1>
															1
														</option>

													</select>
													成新
												</td>
											</tr>

											<tr Class=td2>
												<td>
													<strong>发布天数</strong>
												</td>
												<td>
													<select name="goods.postDays" size=1>
														<option value=1>
															一天
														</option>
														<option value=3>
															三天
														</option>
														<option value=7>
															一周
														</option>
														<option value=15>
															半个月
														</option>
														<option value=30>
															一个月
														</option>
														<option value=90 selected>
															三个月
														</option>
														<option value=180>
															六个月
														</option>
														<option value=360>
															一年
														</option>
													</select>
												</td>
											</tr>
											<tr Class=td2>
												<td>
													<strong>联系人</strong>
												</td>
												<td>
													<input type=text name="goods.contact" size=30 maxlength=50
														value='${good.contact }'/>
												</td>
											</tr>

											<tr Class=td2>
												<td>
													<strong>Email <font color='#FF0000'>*</font> </strong>
												</td>
												<td>
													<input type=text name="goods.email" size=30 maxlength=50
														value='${ good.email}'/>
												</td>
											</tr>
											<tr Class=td2>
												<td>
													<strong>联系电话</strong>
												</td>
												<td>
													<input type=text name="goods.phone" size=30 maxlength=50
														value='${good.phone }'/>
													<br/>
													如为座机或小灵通请填写：区号-电话号码
												</td>
											</tr>

											<tr Class=td2>
												<td>
													<strong>联系地址</strong>
												</td>
												<td>
													<input type=text name="goods.address" size=30 maxlength=200
														value='${good.address }'/>
												</td>
											</tr>

											<tr Class=td2>
												<td>
													<strong>QQ</strong>
												</td>
												<td>
													<input type=text name="goods.qq" size=30 maxlength=12
														value='${good.qq }'/>
												</td>
											</tr>

											<tr Class=td2>
												<td>
													<br/>
												</td>
												<td>
													<input type=submit value='提交信息' name=B1/>
												</td>
											</tr>

										</table>

									</table>
								</form>


								<!-- right end -->
							</td>
						</tr>
						<tr>
							<td>
								<img src="../imgs/center_bottom.gif"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>


		</table>


	</body>
</html>
